<!--[include file='admin_std_header.htm']-->
<script type="text/javascript" src="javascript/ajax/prototype.js"></script>
<script type="text/javascript">
  function validateForm(form) {
  //alert('AAA');

     //Check name
    var subcate = document.getElementById("form_subcategories_name_");
    //alert(subcate);
    if (subcate.value == '') {
      alert("Please enter your subcategory name.");
      document.getElementById('error-subcate').innerHTML = "<FONT  COLOR=\"#FF0000\">Enter your subcategory name.</FONT>";
      subcate.focus();
      return false;
    }

    //Check category prefix
    var prefix = document.getElementById("form_subcategories_prefix_");
    var regexNum = /\d/;
    var regexLetter = /[a-zA-z]/;
    if (prefix.value == '') {
      alert("กรุณาใส่รหัสอักษรอังกฤษ");
      document.getElementById('form_subcategories_prefix_').innerHTML = " <FONT COLOR=\"#FF0000\">Enter Category prefix.</FONT>";
      prefix.focus();
      return false;
    }else{
      document.getElementById('error-category_prefix').innerHTML = "";
    }
    if (prefix.length > 1) {
      alert('กรุณาใส่รหัสอักษรอังกฤษ 1 ตัว');
      prefix.focus();
      return false;
    }
    if(regexNum.test(prefix.value) && !regexLetter.test(prefix.value)){
      alert('เฉพาะตัวอักษรอังกฤษเท่านั้น!!');
      prefix.focus();
      return false;
    }

  }
</script>


<fieldset>
<legend>หมวดหมู่ย่อย</legend>

<form id='form' class='form' action="<!--[pnmodurl modname='IShopStore' type='adminform' func='submit' ctrl='SubCategories']-->" method="post" enctype="multipart/form-data" onsubmit="return validateForm(this)">
<input type="hidden" name="form[id]" value="<!--[$_GET.id]-->" />
<table width="50%" border="0" class="innoadvert-table">
  <tr>
    <td width="26%" class='td-label'>หมวดหมู่</td>
    <td>
      <!--[selector_object_array modname="IShopStore" 
            class="Categories" 
            field="id" 
            displayField="name"  
            name="form[categories_id]" 
            selectedValue=$form.categories_id 
      ]-->
    </td>
  </tr>

  <tr>
    <td width="26%" class='td-label'>หมวดหมู่ย่อย</td>
    <td width="74%">
    <TABLE>
    <TR>
      <TD>
        <input id="form_subcategories_name_" type="text" name="form[name]" value="<!--[$form.name]-->" />
        <FONT COLOR="#FF0000">*</FONT>
      </TD>
      <TD><div id="error-subcate"></div></TD>
    </TR>
    </TABLE>
    </td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td>
      <!--[if $form.id]--><INPUT TYPE="submit" value='Update' name='Update' type="submit" ><!--[/if]-->
      <!--[if $form.id==null]--><INPUT TYPE="submit" value='Submit' name='Submit' type="submit" ><!--[/if]-->
    </td>
  </tr>
</table>

</form>
</fieldset>